package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TBalance;
import com.ruoyi.system.service.ITBalanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 余额Controller
 * 
 * @author ruoyi
 * @date 2022-03-17
 */
@RestController
@RequestMapping("/system/balance")
public class TBalanceController extends BaseController
{
    @Autowired
    private ITBalanceService tBalanceService;

    /**
     * 查询余额列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TBalance tBalance)
    {
        startPage();
        List<TBalance> list = tBalanceService.selectTBalanceList(tBalance);
        return getDataTable(list);
    }

    /**
     * 导出余额列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBalance tBalance)
    {
        List<TBalance> list = tBalanceService.selectTBalanceList(tBalance);
        ExcelUtil<TBalance> util = new ExcelUtil<TBalance>(TBalance.class);
        util.exportExcel(response, list, "余额数据");
    }

    /**
     * 获取余额详细信息
     */
    @GetMapping(value = "/{bid}")
    public AjaxResult getInfo(@PathVariable("bid") Long bid)
    {
        return AjaxResult.success(tBalanceService.selectTBalanceByBid(bid));
    }

    /**
     * 新增余额
     */
    @PostMapping
    public AjaxResult add(@RequestBody TBalance tBalance)
    {
        return toAjax(tBalanceService.insertTBalance(tBalance));
    }

    /**
     * 修改余额
     */
    @PutMapping
    public AjaxResult edit(@RequestBody TBalance tBalance)
    {
        return toAjax(tBalanceService.updateTBalance(tBalance));
    }

    /**
     * 删除余额
     */
	@DeleteMapping("/{bids}")
    public AjaxResult remove(@PathVariable Long[] bids)
    {
        return toAjax(tBalanceService.deleteTBalanceByBids(bids));
    }
}
